package com.zut.edu.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.qmuiteam.qmui.layout.QMUIRelativeLayout;
import com.zut.edu.R;
import com.zut.edu.bean.Chart;
import com.zut.edu.widget.LineChartTool;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import lecho.lib.hellocharts.view.LineChartView;

public class StatisticsFirstFragment extends Fragment {
    @BindView(R.id.sf_num)
    TextView sfnum;
    @BindView(R.id.sf_text)
    QMUIRelativeLayout sftext;
    @BindView(R.id.sf_chart)
    QMUIRelativeLayout sfchart;
    @BindView(R.id.sf_line_Chart)
    LineChartView sflineChart;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_statisticsfirst,container,false);
        ButterKnife.bind(this,view);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initLineChart();
        setLayout();
    }
    private void initLineChart(){
        List<Chart> DataList=new ArrayList<>();
        int sum=0;
        int[] num = new int[]{15,25,8,13,16,5,20,23,27,8,15,11};
        for (int i = 0; i < 12; i++) {
            DataList.add(new Chart((float) (num[i]), i + "月"));
            sum=sum+num[i];
        }
        LineChartTool.setChartViewData(DataList, sflineChart);
        sfnum.setText("追溯记录"+sum+"条");
    }
    private void setLayout(){
        sftext.setRadius(25);
        sftext.setShadowColor(getResources().getColor(R.color.qmui_config_color_black));
        sftext.setAlpha(1.0f);
        sftext.setElevation(20);

        sfchart.setRadius(25);
        sfchart.setShadowColor(getResources().getColor(R.color.qmui_config_color_black));
        sfchart.setAlpha(1.0f);
        sfchart.setElevation(20);

    }
}
